import * as THREE from 'three';

// 创建一个空的几何体对象
const geometry = new THREE.BufferGeometry();

const vertices = new Float32Array([
    0, 0, 0,
    300, 0, 0,
    300, 300, 0,
    -300, 300, 0,
    -300, 0, 0,
    -300, 0, 300,
    -300, 300, 300,
    300, 300, 300,
    300, 0, 300,
    0, 0, 300
])

// 使用缓存对象表示顶点数据
const attribute = new THREE.BufferAttribute(vertices, 3);

// 设置几何体的顶点位置属性
geometry.attributes.position = attribute;

// 添加旋转动画
function rotateX() {
    geometry.rotateX(0.001);
    geometry.rotateY(0.001);
    geometry.rotateZ(0.001);
    requestAnimationFrame(rotateX);
}
rotateX();

// 定义线材质
const material = new THREE.LineBasicMaterial({
    color: 0xffff00,
})

// 定义线模型对象 Line、LineSegments、LineLoop
const line = new THREE.Line(geometry, material);

export default line;